﻿@using Orchard.Themes.Models
@using Orchard.Mvc.Html
@using Orchard.Environment.Extensions.Models

@{ string themeClasses = Model.ContentPart.IsRecentlyInstalled ? "recentlyInstalledTheme" : string.Empty; }

<div>
    <h3@{ if(!string.IsNullOrEmpty(themeClasses)) {<text>  class="@themeClasses"</text>}}>@Model.ContentPart.Name</h3>

    @Html.Image(Href(Html.ThemePath((ExtensionDescriptor) Model.ContentPart.Descriptor, "/Theme.png")), Html.Encode((string)Model.ContentPart.Name), null)
    @using (Html.BeginFormAntiForgeryPost(Url.Action("Activate"), FormMethod.Post, new { @class = "inline" })) {
        @Html.Hidden("themeId", (string)Model.ContentPart.Descriptor.Id)
        <button type="submit" title="@T("Activate")">@T("Set Current")</button>
    }

    @using (Html.BeginFormAntiForgeryPost(Url.Action("Preview"), FormMethod.Post, new { @class = "inline" })) {
        @Html.Hidden("themeId", (string)Model.ContentPart.Descriptor.Id)
        <button type="submit" title="@T("Preview")">@T("Preview")</button>
    }

    <p class="themeInfo smallText">
        @T("By") @Model.ContentPart.Descriptor.Author<br />
        @T("Version:") @Model.ContentPart.Descriptor.Version<br />
        @Model.ContentPart.Descriptor.Description<br />
        @if (Model.ContentPart.Descriptor.WebSite != null) {
            <a href="@Model.ContentPart.Descriptor.WebSite">@Model.ContentPart.Descriptor.WebSite</a><br />
        }
    </p>

    @if (Model.ContentPart.Notifications != null && Model.ContentPart.Notifications.Count > 0) {
        <ul class="notifications">
        @foreach (string notification in Model.ContentPart.Notifications) {
            <li>@notification</li>
        }
        </ul>
    }

    @if (Model.ContentPart.Enabled) {
        using (Html.BeginFormAntiForgeryPost(Url.Action("Disable"), FormMethod.Post, new { @class = "inline link" })) {
            @Html.Hidden("themeId", (string)Model.ContentPart.Descriptor.Id)
            <button type="submit" class="disable" title="Disable">@T("Disable")</button>
        }
    }
    else {
        using (Html.BeginFormAntiForgeryPost(Url.Action("Enable"), FormMethod.Post, new { @class = "inline link" })) {
            @Html.Hidden("themeId", (string)Model.ContentPart.Descriptor.Id)
            <button type="submit" class="enable" title="Enable">@T("Enable")</button>
        }
    }

    @if (Model.ContentPart.NeedsUpdate) {
        <span> | </span>
        using (Html.BeginFormAntiForgeryPost(Url.Action("Update"), FormMethod.Post, new { @class = "inline link" })) {
            @Html.Hidden("themeId", (string)Model.ContentPart.Descriptor.Id)
            <button type="submit" class="update">@T("Update")</button> <br/>
        }
    }

    @if (Model.ContentPart.CanUninstall) {
        <span> | </span>
        using (Html.BeginFormAntiForgeryPost(Url.Action("RemoveTheme", "PackagingServices", new { area = "Orchard.Packaging", returnUrl = HttpContext.Current.Request.RawUrl, retryUrl = HttpContext.Current.Request.RawUrl, themeId = Model.ContentPart.Descriptor.Id }), FormMethod.Post, new { @class = "inline link" })) {
            <button type="submit" class="uninstall" title="@T("Uninstall")">@T("Uninstall")</button>
        }
    }
</div>